package com.net

import com.github.salomonbrys.kotson.fromJson
import com.google.gson.Gson
import com.google.gson.JsonElement
import com.helloandroid.ext.parseZhuanPanInfo
import com.helloandroid.ext.process
import org.json.JSONObject
import org.junit.Test

class TestGameZhuanPan {

    @Test
    fun test_zhuanpan(){
        val str = """
            {"err":0,"json":1,"data":"{\"OppoX2\": 0, \"VivoX60\": 0, \"restcount\": 2, \"usedcount\": 8, \"awardstate\": [0, 1, 0], \"XiaoMi10Pro\": 0, \"hwMate40Pro\": 4, \"iphone12Pro\": 2}","serverTime":1614047969827}
        """.trimIndent()

//        val jsonObj = (Gson().fromJson(str) as JsonElement).asJsonObject
//        val err = jsonObj.get("err").asInt
//        log("err:$err")

        val jsonObj = JSONObject(str)
        val parseResult = jsonObj.process(JSONObject::parseZhuanPanInfo)
    }
}